From 2fbd6e8d0cb42507831847982ea3937e2c13ace0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali.rohar@gmail.com>
Date: Tue, 13 Aug 2019 00:49:17 +0200
Subject: [PATCH] all: Allow to build udftools without udev

If udev is not found during configure phase then do not install pktsetup
udev rules file. udev itself is not used for anything else.

Fixes: https://github.com/pali/udftools/issues/30
[Retrieved from:
https://github.com/pali/udftools/commit/2fbd6e8d0cb42507831847982ea3937e2c13ace0]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 configure.ac         | 3 ++-
 pktsetup/Makefile.am | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 63bef62..d71fee8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,7 +25,8 @@ AC_C_BIGENDIAN
 AC_SYS_LARGEFILE
 
 PKG_PROG_PKG_CONFIG
-PKG_CHECK_MODULES(UDEV, [udev], [ac_cv_udevdir=`$PKG_CONFIG --variable=udevdir udev`])
+PKG_CHECK_MODULES(UDEV, [udev], [ac_cv_udevdir=`$PKG_CONFIG --variable=udevdir udev`], [ac_cv_udevdir=""])
+AM_CONDITIONAL(UDEVDIR, [test "$ac_cv_udevdir" != ""])
 AC_SUBST(UDEVDIR, $ac_cv_udevdir)
 
 dnl Checks for library functions.
diff --git a/pktsetup/Makefile.am b/pktsetup/Makefile.am
index 0c5fd1c..33da370 100644
--- a/pktsetup/Makefile.am
+++ b/pktsetup/Makefile.am
@@ -2,9 +2,13 @@ sbin_PROGRAMS = pktsetup
 pktsetup_SOURCES = pktsetup.c
 EXTRA_DIST = pktsetup.rules
 
+if UDEVDIR
+
 install-data-local:
 	mkdir -p "$(DESTDIR)$(UDEVDIR)/rules.d"
 	$(INSTALL_DATA) "$(srcdir)/pktsetup.rules" "$(DESTDIR)$(UDEVDIR)/rules.d/80-pktsetup.rules"
 
 uninstall-local:
 	rm -f "$(DESTDIR)$(UDEVDIR)/rules.d/80-pktsetup.rules"
+
+endif
